package com.sys.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sys.dao.CourseDao;
import com.sys.entity.Course;
import com.sys.service.CourseService;

@Service
public class CourseServiceImpl implements CourseService {

	@Autowired
	private CourseDao CourseDao;

	@Override
	public Map<String, Object> getAllCourse(String coname,Integer del,Integer page, Integer limit) {
		Map<String, Object> prams = new HashMap<String, Object>();
		prams.put("coname", coname);
		prams.put("del", del);
		page = (page - 1) * limit;
		prams.put("page", page);
		prams.put("limit", limit);
		List<Course> list = CourseDao.getAllCourse(prams);
		int total = CourseDao.getAllCourseCount(prams);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("list", list);
		map.put("total", total);
		return map;
	}

	@Override
	public int addCourse(Course course) {
		int len = CourseDao.addCourse(course);
		return len;
	}

	@Override
	public int updateCourse(Course course) {
		int len = CourseDao.updateCourse(course);
		return len;
	}

	@Override
	public int deleteCourse(Integer coid) {
		int len = CourseDao.deleteCourse(coid);
		return len;
	}

	@Override
	public List<Course> getCourseByCid(Integer cid) {
		// TODO Auto-generated method stub
		return CourseDao.getCourseByCid(cid);
	}

}
